<?php
/*
  Document   : Nieuws toevoegen
  Created on : 12-mei-2011, 12:05:08
  Author     : Shahram abdi
 */
// Make sure the user is logged in before going any further.
if (!isset($_SESSION['username'])) {
    echo '<p>Please <a href="login.php">log in</a> to access this page.</p>';
    exit();
}
require_once("nieuwsDB.class.php");

if (isset($_POST['submit'])) {
// create a new Beheer instance
    $beheer = new Beheer();
    $titel = $_POST['titel'];
    $tekst = $_POST['tekst'];
    $link = $_POST['link'];

// check if we have valid values
    if ($titel != '' && $tekst != '') {
        // post the message to the database
        $beheer->postMessage($titel, $tekst, $link);
    }
} else {
?>
    <div id="signup">
        <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
            <fieldset><label for="titel">Titel:</label>
                <input name="titel" id="titel" type="text" /></fieldset>

            <fieldset><label for="link">Link:</label>
                <input name="link" id="link" type="text" /></fieldset>

            <fieldset><label for="tekst">Tekst:</label>
                <textarea cols="" rows=""  name="tekst" id="tekst"></textarea></fieldset>

            <fieldset class="nolabel">
                <input type="submit" name="submit" value="submit" />
            </fieldset>
        </form>
    </div>
<?php
}
?>